/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.vod.gauss.net;

import fr.vod.gauss.matrice.Equation;
import fr.vod.gauss.matrice.EquationImpl;
import fr.vod.gauss.utils.Convert;

/**
 *
 * @author drazanakoto
 */
public class FormatImpl implements Format {

    @Override
    public Equation format(byte[] msg, int blockSize, int packetSize) {
        int[] tab = new int[blockSize];
        int tmp;
        for (int i = 0; i < packetSize; i++) {
            tmp = Convert.byteToUint8(msg[i]);
            tab[tmp] = Convert.byteToUint8(msg[packetSize + i]);

        }
        return new EquationImpl(tab, Convert.byteToUint8(msg[2 * packetSize]));
    }
}
